
package GUI;

import java.awt.Color;


public class Quadrado {

    private int[] x;
    private int[] y;
    private int tipo;
    private int altura;
    private Color cor;
    private int[] xEx;
    private int[] yEx;
    private int ang = 0;


    public Quadrado(int x, int y, int altura, int tipo, Color cor) {
        this.altura = altura;
        this.tipo = tipo;
        this.cor = cor;
        //quadrado...
        if (tipo <= 2) {
            this.x = new int[4];             //   x[0]y[0]------------- x[1]y[1]
            this.y = new int[4];             //       |                     |
            this.x[0] = x;                   //       |                     |
            this.y[0] = y;                   //   x[3]y[3]------------- x[2]y[2]
            this.x[1] = x + altura;
            this.y[1] = y;
            this.x[3] = x;
            this.y[3] = y + altura;
            this.x[2] = x + altura;
            this.y[2] = y + altura;
        } else {
            // triangulo...
            this.x = new int[4];             //            x[0]y[0]
            this.y = new int[4];             //          /          \
            this.x[0] = x + altura / 2;      //       /                \
            this.y[0] = y;                   //   x[1]y[1]------------ x[2]y[2]
            this.x[1] = x;
            this.y[1] = y + altura;
            this.x[2] = x + altura;
            this.y[2] = y + altura;
        }
    }

    public Quadrado(int x, int y, int altura, int largura, int tipo, Color cor) {
        this.altura = altura;
        this.tipo = tipo;
        this.cor = cor;
        //quadrado...
        this.x = new int[4];             //   x[0]y[0]------------- x[1]y[1]
        this.y = new int[4];             //       |                     |
        this.x[0] = x;                   //       |                     |
        this.y[0] = y;                   //   x[3]y[3]------------- x[2]y[2]
        this.x[1] = x + largura;
        this.y[1] = y;
        this.x[3] = x;
        this.y[3] = y + altura;
        this.x[2] = x + largura;
        this.y[2] = y + altura;
    }

    public void expandirQuadro(int raio) {
        int raiox = (int) (raio / Math.sqrt(2));

        if (x.length == 4) {
            xEx = new int[12];
            yEx = new int[12];

            xEx[0] = x[0];
            yEx[0] = y[0] - raio;
            xEx[1] = x[1];
            yEx[1] = y[1] - raio;
            xEx[2] = x[1] + raiox;
            yEx[2] = y[1] - raiox;
            xEx[3] = x[1] + raio;
            yEx[3] = y[1];
            xEx[4] = x[2] + raio;
            yEx[4] = y[2];
            xEx[5] = x[2] + raiox;
            yEx[5] = y[2] + raiox;
            xEx[6] = x[2];
            yEx[6] = y[2] + raio;
            xEx[7] = x[3];
            yEx[7] = y[3] + raio;
            xEx[8] = x[3] - raiox;
            yEx[8] = y[3] + raiox;
            xEx[9] = x[3] - raio;
            yEx[9] = y[3];
            xEx[10] = x[0] - raio;
            yEx[10] = y[0];
            xEx[11] = x[0] - raiox;
            yEx[11] = y[0] - raiox;
        }
    }

    public Color getCor() {
        return cor;
    }

    public int getTipo() {
        return tipo;
    }

    public int getAltura() {
        return altura;
    }

    public int[] getxEx() {
        return xEx;
    }

    public int[] getyEx() {
        return yEx;
    }

    public int[] getX() {
        return x;
    }

    public int[] getY() {
        return y;
    }

    public void setX(int[] x) {
        this.x = x;
    }

    public void setY(int[] y) {
        this.y = y;
    }

    public int getAng() {
        return ang;
    }

    public void setAng(int ang) {
        this.ang = ang;
    }
}
